#!/bin/sh

version=$1

file=global-cron-web-$version.war

cd ~/tomcat/bin
./shutdown.sh

sleep 10

rm -vf $file

cd ~
wget -O $file http://localhost:8081/nexus/service/local/artifact/maven/redirect?r=releases\&g=com.rupertjones.global-cron\&a=global-cron-web\&v=$version\&e=war

cd ~/tomcat/webapps
rm -rvf global-cron*

cd ~/tomcat/work/Catalina/localhost
rm -vrf global-cron*

cd ~/tomcat/webapps
ln -s ~/$file global-cron.war

cd ~/tomcat/bin
./startup.sh
